btez2 2.2.0
Loading...
Searching...
No Matches
main.c File Reference

BT-EZ 2 Click Example. More...

#include "board.h"
#include "log.h"
#include "btez2.h"

Macros

#define MESSAGE_CONTENT   "BT-EZ 2 Click board - demo example."
#define APP_BUFFER_SIZE   500
#define PROCESS_BUFFER_SIZE   200
#define BT_TERMINAL_TIMEOUT_MS   60000
#define BT_TERMINAL_MESSAGE_FREQ_MS   5000

Enumerations

enum  btez2_app_state_t { BTEZ2_POWER_UP = 1 , BTEZ2_CONFIG_EXAMPLE , BTEZ2_EXAMPLE }
 Example states. More...

Functions

void application_init (void)
void application_task (void)
int main (void)

Detailed Description

BT-EZ 2 Click Example.

Description

This example demonstrates the use of BT-EZ 2 Click board by processing data from a connected BLE device.

The demo application is composed of two sections :

Application Init

Initializes the driver and logger.

Application Task

Application task is split in few stages:

  • BTEZ2_POWER_UP: Powers up the device and checks the communication.
  • BTEZ2_CONFIG_EXAMPLE: Restores factory settings and reads the BT address and name.
  • BTEZ2_EXAMPLE: Performs a BT terminal example by processing all data from a connected BLE device and sending back an adequate response messages.

Additional Function

  • static void btez2_clear_app_buf ( void )
  • static void btez2_log_app_buf ( void )
  • static err_t btez2_process ( btez2_t *ctx )
  • static err_t btez2_wait_packet ( btez2_t *ctx, uint8_t timeout_s, uint8_t rsp_flag, uint8_t *cmd_code )
  • static err_t btez2_power_up ( btez2_t *ctx )
  • static err_t btez2_config_example ( btez2_t *ctx )
  • static err_t btez2_example ( btez2_t *ctx )
Note
We have used the Serial Bluetooth Terminal smartphone application for the test.
Author
Stefan Filipovic

Macro Definition Documentation

◆ APP_BUFFER_SIZE

#define APP_BUFFER_SIZE   500

◆ BT_TERMINAL_MESSAGE_FREQ_MS

#define BT_TERMINAL_MESSAGE_FREQ_MS   5000

◆ BT_TERMINAL_TIMEOUT_MS

#define BT_TERMINAL_TIMEOUT_MS   60000

◆ MESSAGE_CONTENT

#define MESSAGE_CONTENT   "BT-EZ 2 Click board - demo example."

◆ PROCESS_BUFFER_SIZE

#define PROCESS_BUFFER_SIZE   200

Enumeration Type Documentation

◆ btez2_app_state_t

Example states.

Predefined enum values for application example state.

Enumerator
BTEZ2_POWER_UP 
BTEZ2_CONFIG_EXAMPLE 
BTEZ2_EXAMPLE 

Function Documentation

◆ application_init()

void application_init ( void )

< Logger config object.

< Click config object.

Logger initialization. Default baud rate: 115200 Default log level: LOG_LEVEL_DEBUG

Note
If USB_UART_RX and USB_UART_TX are defined as HAL_PIN_NC, you will need to define them manually for log to work. See LOG_MAP_USB_UART macro definition for detailed explanation.

◆ application_task()

void application_task ( void )

◆ main()

int main ( void )